package org.example.entity;

import com.sun.source.doctree.DeprecatedTree;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.sql.ResultSet;
import java.sql.SQLException;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Item {
     private int itemId;
     private int ordId;
     private int proId;
     private String proName;
     private int quantity;
     private double subtotal;

    public Item(int ordId, int proId, String proName, int quantity, double subtotal){
    this.ordId=ordId;
    this.proId=proId;
    this.proName=proName;
    this.quantity=quantity;
    this.subtotal=subtotal;
}

    public static Item map(ResultSet rs) throws SQLException{
        Item item = new Item();
        item.setItemId(rs.getInt("item_id"));
        item.setOrdId(rs.getInt("ord_id"));
        item.setProId(rs.getInt("pro_id"));
        item.setProName(rs.getString("pro_name"));
        item.setQuantity(rs.getInt("quantity"));
        item.setSubtotal(rs.getDouble("subtotal"));
        return item;
    }
}
